//
//  JddTabBar.m
//  PlayBall
//
//  Created by Edward Zhang on 12-5-4.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "JddTabBar.h"

@interface JddTabBar (){
    //remove  by rainy
//    UIImageView *_imageView;
}

@end
@implementation JddTabBar
GET_INSTANCE_VIEW_IMPLEMENT(JddTabBar)


@synthesize item1;
@synthesize item2;
@synthesize item3;
//@synthesize item4;
@synthesize item5;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
//        tabBar.selectedImageTintColor = [UIColor colorWithRed:253/255.0f green:52/255.0f blue:58/255.0f alpha:1.0];

    }
    return self;
}
- (void)awakeFromNib
{
    //remove  by rainy
//    _imageView = [[UIImageView alloc] init];
    self.backgroundColor = [UIColor colorWithRed:247/255.0f green:247/255.0f blue:247/255.0f alpha:1.0];
//    self.selectedImageTintColor = [UIColor colorWithRed:253/255.0f green:52/255.0f blue:58/255.0f alpha:1.0];

    [self.item1 setImage:[UIImage imageNamed:@"home"]];
    [self.item1 setSelectedImage:[UIImage imageNamed:@"home_hover"]];
    [self.item2 setImage:[UIImage imageNamed:@"bag"]];
    [self.item2 setSelectedImage:[UIImage imageNamed:@"bag_hover"]];
    [self.item3 setImage:[UIImage imageNamed:@"fuwu"]];
    [self.item3 setSelectedImage:[UIImage imageNamed:@"fuwu_hover"]];
    [self.item5 setImage:[UIImage imageNamed:@"wo"]];
    [self.item5 setSelectedImage:[UIImage imageNamed:@"wo_hover"]];
    

    //remove  by rainy
//    _imageView.frame = CGRectMake(138.0f, 8.0f, 45.0f, 37.0f);
//    _imageView.backgroundColor = [UIColor clearColor];
//    [_imageView setImage:[UIImage imageNamed:@"fiveMatch_normal_icon"]];
//    [self addSubview:_imageView];
}

- (void)show {
    [UIView animateWithDuration:0.3 animations:^{
        [self setTop:[[UIScreen mainScreen] bounds].size.height - self.height];
    }];
}

- (void)hide {
    [UIView animateWithDuration:0.3 animations:^{
        [self setTop:[[UIScreen mainScreen] bounds].size.height];
    }];
}

//
- (void)setTabItemFiveMatchSelected:(BOOL)flag{
    //remove  by rainy
//    if (flag) {
//        [_imageView setImage:[UIImage imageNamed:@"fiveMatch_clicked_icon"]];
//    }else{
//        [_imageView setImage:[UIImage imageNamed:@"fiveMatch_normal_icon"]];
//    }
}

// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{

//    CAGradientLayer *gradient = [[CAGradientLayer alloc] init];
//    
//    gradient.frame = rect;
//    
//    UIColor *firstColor = [[UIColor alloc] initWithRed:252.0/255.0 green:53.0/255.0 blue:53.0/255.0 alpha:1.0];
//    UIColor *secondColor = [[UIColor alloc] initWithRed:252.0/255.0 green:53.0/255.0 blue:53.0/255.0 alpha:1.0];
//    UIColor *thirdColor = [[UIColor alloc] initWithRed:195.0/255.0 green:25.0/255.0 blue:17.0/255.0 alpha:1.0];
//    
//    gradient.colors = [NSArray arrayWithObjects:(id)firstColor.CGColor, (id)secondColor.CGColor, (id)thirdColor.CGColor, nil];
//
    
    //一根r、g、b都为193的细线
    CGContextRef context = UIGraphicsGetCurrentContext();//创建一块画板
    CGContextMoveToPoint(context,rect.origin.x, rect.origin.y);//画笔起点，第一个参数就是画板，后两个参数为起点的x和y坐标
    CGContextAddLineToPoint(context, rect.origin.x + rect.size.width, rect.origin.y);//画笔终点，第一个参数就是画板，后两个参数为终点的x和y坐标
    CGContextSetLineWidth(context, 0.7);//綫有多粗
    UIColor *color1 = [UIColor colorWithRed:180/255.0f green:180/255.0f blue:180/255.0f alpha:1.0];
    CGContextSetStrokeColorWithColor(context, color1.CGColor);//线的颜色，第二个参数是CGColor，需要转一下
    CGContextDrawPath(context, kCGPathStroke);//画，第二个参数是都描绘什么，可选择只画线，或者只填充，或者都画

    //一根r、g、b都为153的细线
    UIColor *color2 = [UIColor colorWithRed:135/255.0f green:135/255.0f blue:135/255.0f alpha:1.0];
    CGContextMoveToPoint(context,rect.origin.x, rect.origin.y+0.7);
    CGContextAddLineToPoint(context, rect.origin.x + rect.size.width, rect.origin.y+0.7);
    CGContextSetLineWidth(context, 0.7);
    CGContextSetStrokeColorWithColor(context, color2.CGColor);
    CGContextDrawPath(context, kCGPathStroke);
    //一根1像素的白线
    CGContextMoveToPoint(context,rect.origin.x, rect.origin.y+1.4);
    CGContextAddLineToPoint(context, rect.origin.x + rect.size.width, rect.origin.y+1.4);
    CGContextSetLineWidth(context, 1.0);
    CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);
    CGContextDrawPath(context, kCGPathStroke);
}


@end
